#include "testqstring.h"

TestQString::TestQString(QObject *parent) :
    QObject(parent)
{
}


void TestQString::TestToUpper()
{
    QString str = "Hello";
    QVERIFY(str.toUpper() == "HELLO");
    str.chop(2);
    QCOMPARE(str, QString("Hel"));
    str += " Qt";
    QVERIFY(str == QString("Hel Qt"));
}

void TestQString::TestChop()
{
    QString str = "Hello";
    str.chop(2);
    QCOMPARE(str, QString("Hel"));
}

void TestQString::TestAppend()
{
    QString str = "Hello";
    str += " Qt";
    QVERIFY(str == QString("Hel Qt"));
}


void TestQString::TestToUpperData_data()
{
     QTest::addColumn<QString>("string");
     QTest::addColumn<QString>("result");

     QTest::newRow("all lower") << "hello" << "HELLO";
     QTest::newRow("mixed")     << "HeLlo" << "HELLO";
     QTest::newRow("all upper") << "HELLO" << "HELLO";
}

void TestQString::TestToUpperData()
{
     QFETCH(QString, string);
     QFETCH(QString, result);

     QCOMPARE(string.toUpper(), result);
}

QTEST_MAIN(TestQString)
